package com.xc.tjise.TJISE.day10;

import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class BatchTest {// .bat 批处理文件

    public static void main(String[] args) throws SQLException {
        new Driver();
        Connection connection = DBCPDatasource.getconnection();
        String SQL = "INSERT INTO db_csdn.csdn VALUES(NULL,?,?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(SQL);
        String[][] datas = {

//                {"u1", "p1", "e1"},
//                {"u2", "p2", "e2"},
//                {"u3", "p3", "e3"},
//                {"u4", "p4", "e4"},
//                {"u5", "p5", "e5"}
        };
        for(int i=0;i<datas.length;i++){
            preparedStatement.setString(1,datas[i][0]);
            preparedStatement.setString(2,datas[i][1]);
            preparedStatement.setString(3,datas[i][2]);

            preparedStatement.addBatch();
        }
        preparedStatement.executeBatch();
    }
}
